<script lang="ts" setup>
import { computed } from "vue";
import { getSize } from "../utils";

interface ImageProps {
  src?: string;
  width?: number | string;
  height?: number | string;
}

const { width, height } = defineProps<ImageProps>();

const styles = computed(() => ({
  width: getSize(width),
  height: getSize(height),
}));
</script>

<template>
  <div class="umi-image" :style="styles">
    <img :src="src" v-if="src" />
    <iconpark-icon v-else name="picture"></iconpark-icon>
  </div>
</template>

<style lang="scss" scoped>
.umi-image {
  font-size: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #ccc;

  > img {
    height: 100%;
    width: 100%;
  }
}
</style>
